<?php

declare(strict_types=1);

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

/**
 * 女用户白名单
 */
class WhiteHost extends Model
{
    protected $table = 'white_host';

    protected $fillable = [
        'user_id', 'flag'
    ];

    public function userInfo()
    {
        return $this->belongsTo(UserProfile::class, 'user_id', 'user_id');
    }

    static function checkWhite($userId = 0)
    {
        return self::where(['user_id' => $userId, 'flag' => 1])->count() > 0;
    }

    static function addHost($userId = 0)
    {
        return self::create([
            'user_id' => $userId,
            'flag' => 1
        ]);
    }
}
